package com.zhangxiaofanfan.hotcode.first;

import java.util.ArrayList;
import java.util.List;

/**
 * <a href="https://leetcode.cn/problems/rotting-oranges/?envType=study-plan-v2&envId=top-100-liked">994. 腐烂的橘子</a>
 *
 * @author zhangxiaofanfan
 * @date 2024-06-26 20:33:33
 */
public class HotCode052 {
    public static void main(String[] args) {

    }

    public int orangesRotting(int[][] grid) {
        int time = 1, row = grid.length, col = grid[0].length, rowIndex, colIndex;
        while (true) {

        }
    }

    public List<Integer> rotOrange(int[][] grid, int rowIndex, int colIndex) {
        List<Integer> list = new ArrayList<>();
        int up = rowIndex - 1, down = rowIndex + 1, left = colIndex - 1, right = colIndex + 1, row = grid.length, col = grid[0].length;
        if (up >= 0 && grid[up][colIndex] == 1) {
            list.add(up * row + colIndex);
            grid[up][col] = 2;
        }
        if (left >= 0 && grid[rowIndex][left] == 1) {
            list.add(rowIndex * row + left);
            grid[rowIndex][left] = 2;
        }
        if (down < row && grid[down][colIndex] == 1) {
            list.add(down * row + colIndex);
            grid[down][col] = 2;
        }
        if (right < col && grid[rowIndex][right] == 1) {
            list.add(rowIndex * row + right);
            grid[rowIndex][right] = 2;
        }
        return list;
    }
}
